<?php
/**
 * Created by PhpStorm.
 * User: s.utkin
 * Date: 23.10.14
 * Time: 15:46
 */

namespace Pinenut\Test;


class MockSetManager
{
	public static $mocksetsBasePath;
	protected static $baseIncludePathList = '';
	protected static $includePathList = [];

	public static function add($setName)
	{
		if (empty(static::$baseIncludePathList)) {
			static::$baseIncludePathList = get_include_path();
		}

		$newPath = static::$mocksetsBasePath . "/$setName/";
		static::$includePathList[] = $newPath;

		static::calculateIncludePath();
	}

	public static function clear()
	{
		static::$includePathList = [];
		static::calculateIncludePath();
	}

	protected function calculateIncludePath()
	{
		$newPart = '';
		if (!empty(static::$includePathList)) {
			$newPart = implode(':', array_reverse(static::$includePathList)) . ':';
		}

		$newIncludePathString =  $newPart . static::$baseIncludePathList;
		set_include_path($newIncludePathString);
	}
} 